
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.inline {
  background-color: #f7f7f7;
  border:solid 1px #B0B0B0;
}
.error {
	font-weight: bold;
	color: #FF0000;
}
.warning {
	font-weight: bold;
}
.message {
	font-style: italic;
}
.source, .output, .warning, .error, .message {
	padding: 0 1em;
  border:solid 1px #F7F7F7;
}
.source {
  background-color: #f5f5f5;
}
.left {
  text-align: left;
}
.right {
  text-align: right;
}
.center {
  text-align: center;
}
.hl.num {
  color: #AF0F91;
}
.hl.str {
  color: #317ECC;
}
.hl.com {
  color: #AD95AF;
  font-style: italic;
}
.hl.opt {
  color: #000000;
}
.hl.std {
  color: #585858;
}
.hl.kwa {
  color: #295F94;
  font-weight: bold;
}
.hl.kwb {
  color: #B05A65;
}
.hl.kwc {
  color: #55aa55;
}
.hl.kwd {
  color: #BC5A65;
  font-weight: bold;
}
</style>
  <script src="https://yihui.name/media/js/center-images.js"></script>
  <title>A Report Generated by knitr</title>
</head>
<body>

  <p>This report is automatically generated with the R
    package <a href="https://urldefense.com/v3/__https://yihui.name/knitr/__;!!KwNVnqRv!Qe-exEu_89J5vvEI1u-pbcrXYGLK45EjLOfXuHezEI1gG0Ck0tDXhU1bTDF12vU$"><strong>knitr</strong></a>
    (version <code class="knitr inline">1.31</code>)
    .</p>

<div class="chunk" id="auto-report"><div class="rcode"><div class="source"><pre class="knitr r"><span class="hl com">#### DATA PREPARATION ####</span>

<span class="hl com"># setwd(&quot;/Users/oyvindskorge/Dropbox/Papers/Giani-Hope-Skorge/7-Replication/&quot;)</span>

<span class="hl com">#### SETUP ####</span>

<span class="hl kwa">if</span> <span class="hl std">(</span><span class="hl opt">!</span><span class="hl kwd">require</span><span class="hl std">(pacman)) {</span>
  <span class="hl kwd">install.packages</span><span class="hl std">(</span><span class="hl str">&quot;pacman&quot;</span><span class="hl std">)</span>
  <span class="hl kwd">require</span><span class="hl std">(pacman)</span>
<span class="hl std">}</span>

<span class="hl kwd">p_load</span><span class="hl std">(data.table,estimatr,lfe,</span>
       <span class="hl std">tidyverse, sjlabelled, sjmisc,</span>
       <span class="hl std">swfscMisc, mgcv, devtools,</span> <span class="hl kwc">update</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">)</span>

<span class="hl com"># inteflex version &gt;=1.1.3 needed for the analyses,</span>
<span class="hl com"># which can be installed by running the following line:</span>
<span class="hl com"># devtools::install_github(&quot;xuyiqing/interflex&quot;)</span>
<span class="hl kwd">p_load</span><span class="hl std">(interflex,</span> <span class="hl kwc">install</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">,</span> <span class="hl kwc">update</span><span class="hl std">=</span><span class="hl num">FALSE</span><span class="hl std">)</span>

<span class="hl kwd">source</span><span class="hl std">(</span><span class="hl str">&quot;utils.r&quot;</span><span class="hl std">)</span>

<span class="hl com">#### DATA ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">sjlabelled</span><span class="hl opt">::</span><span class="hl kwd">read_data</span><span class="hl std">(</span><span class="hl str">&quot;ESSgenderUpdate1.dta&quot;</span><span class="hl std">)</span>

<span class="hl com">#### RECODING OF VARIABLES ####</span>

<span class="hl com">#### Education and household education gap  ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">Education</span> <span class="hl std">=</span> <span class="hl kwd">ifelse</span><span class="hl std">(eisced</span><span class="hl opt">&lt;</span><span class="hl num">8</span><span class="hl std">,eisced,</span><span class="hl num">NA</span><span class="hl std">))</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">Education_partner</span> <span class="hl std">=</span> <span class="hl kwd">ifelse</span><span class="hl std">(eiscedp</span><span class="hl opt">&lt;</span><span class="hl num">8</span><span class="hl std">,eiscedp,</span><span class="hl num">NA</span><span class="hl std">))</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">Edu_diff</span> <span class="hl std">=</span> <span class="hl kwd">ifelse</span><span class="hl std">(eisced</span><span class="hl opt">&lt;</span><span class="hl num">8</span><span class="hl std">,eisced,</span><span class="hl num">NA</span><span class="hl std">)</span> <span class="hl opt">-</span> <span class="hl kwd">ifelse</span><span class="hl std">(eiscedp</span><span class="hl opt">&lt;</span><span class="hl num">8</span><span class="hl std">,eiscedp,</span><span class="hl num">NA</span><span class="hl std">))</span>

<span class="hl com">#### Income ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">Income</span> <span class="hl std">=</span> <span class="hl kwd">as_numeric</span><span class="hl std">(Income,</span><span class="hl kwc">start.at</span><span class="hl std">=</span><span class="hl num">0</span><span class="hl std">))</span>
<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">Income_sq</span> <span class="hl std">= Income</span><span class="hl opt">^</span><span class="hl num">2</span><span class="hl std">)</span>
<span class="hl kwd">summary</span><span class="hl std">(dt</span><span class="hl opt">$</span><span class="hl std">Income_sq)</span>
</pre></div>
<div class="output"><pre class="knitr r">##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    0.00    4.00   16.00   30.44   49.00  100.00    2475
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com">#### Father's education ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">eduFather</span> <span class="hl std">=</span> <span class="hl kwd">rec</span><span class="hl std">(eiscedf,</span> <span class="hl kwc">rec</span><span class="hl std">=</span><span class="hl str">&quot;55=NA;else=copy&quot;</span><span class="hl std">))</span>

<span class="hl com">#### Mothers's education ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">eduMother</span> <span class="hl std">=</span> <span class="hl kwd">rec</span><span class="hl std">(eiscedm,</span> <span class="hl kwc">rec</span><span class="hl std">=</span><span class="hl str">&quot;55=NA;else=copy&quot;</span><span class="hl std">))</span>

<span class="hl com">#### Difference in education ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">eduParentsDiff</span> <span class="hl std">=</span> <span class="hl kwd">remove_all_labels</span><span class="hl std">(eduFather)</span> <span class="hl opt">-</span> <span class="hl kwd">remove_all_labels</span><span class="hl std">(eduMother))</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">var_labels</span><span class="hl std">(</span><span class="hl kwc">eduParentsDiff</span> <span class="hl std">=</span> <span class="hl str">&quot;Education difference between parents&quot;</span><span class="hl std">)</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">eduParentsDiffCat</span> <span class="hl std">=</span> <span class="hl kwd">rec</span><span class="hl std">(eduParentsDiff,</span> <span class="hl kwc">rec</span><span class="hl std">=</span><span class="hl str">&quot;-6:-1=3; 0=2; 1:6=1&quot;</span><span class="hl std">,</span>
                                 <span class="hl kwc">val.labels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Father more&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Equal&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Mother more&quot;</span><span class="hl std">)))</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">var_labels</span><span class="hl std">(</span><span class="hl kwc">eduParentsDiffCat</span> <span class="hl std">=</span> <span class="hl str">&quot;Education difference between parents&quot;</span><span class="hl std">)</span>

<span class="hl com">#### Father's employment when respondent 14 ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">emp14Father</span> <span class="hl std">= emprf14)</span>

<span class="hl com">#### Mother's employment when respondent 14 ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">emp14Mother</span> <span class="hl std">= emprm14)</span>

<span class="hl com">#### Difference between mother and father's employment ####</span>

<span class="hl com"># Categories</span>
  <span class="hl com"># 1 Mother (self) employed, father not (or dead/absent)</span>
  <span class="hl com"># 2 Both (self) employed</span>
  <span class="hl com"># 3 Father (self) employed, mother not (or dead/absent)</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">emp14Diff</span> <span class="hl std">=</span> <span class="hl kwd">ifelse</span><span class="hl std">(emp14Mother</span> <span class="hl opt">%in%</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span> <span class="hl opt">&amp;</span> <span class="hl std">emp14Father</span> <span class="hl opt">%in%</span> <span class="hl num">3</span><span class="hl opt">:</span><span class="hl num">4</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">,</span>
                            <span class="hl kwd">ifelse</span><span class="hl std">(emp14Mother</span> <span class="hl opt">%in%</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span> <span class="hl opt">&amp;</span> <span class="hl std">emp14Father</span> <span class="hl opt">%in%</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">,</span>
                                   <span class="hl kwd">ifelse</span><span class="hl std">(emp14Mother</span> <span class="hl opt">%in%</span> <span class="hl num">3</span><span class="hl opt">:</span><span class="hl num">4</span> <span class="hl opt">&amp;</span> <span class="hl std">emp14Father</span> <span class="hl opt">%in%</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">,</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">NA</span><span class="hl std">))))</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">val_labels</span><span class="hl std">(</span><span class="hl kwc">emp14Diff</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Father employed, mother not&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Both employed&quot;</span><span class="hl std">,</span><span class="hl str">&quot;Mother employed, father not&quot;</span><span class="hl std">))</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">var_labels</span><span class="hl std">(</span><span class="hl kwc">emp14Diff</span> <span class="hl std">=</span> <span class="hl str">&quot;Employment difference between parents&quot;</span><span class="hl std">)</span>

<span class="hl com">#### Weights ####</span>

<span class="hl std">dt</span> <span class="hl kwb">&lt;-</span> <span class="hl std">dt</span> <span class="hl opt">%&gt;%</span>
  <span class="hl kwd">mutate</span><span class="hl std">(</span><span class="hl kwc">wgt</span> <span class="hl std">= dweight</span><span class="hl opt">*</span><span class="hl std">pweight)</span>

<span class="hl com">#### SAVING AMENDED DATA #####</span>

<span class="hl kwd">write_stata</span><span class="hl std">(dt,</span><span class="hl str">&quot;ESSgenderUpdate2.dta&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="message"><pre class="knitr r">## Tidying value labels. Please wait...
</pre></div>
<div class="message"><pre class="knitr r">## Writing stata file to 'ESSgenderUpdate2.dta'. Please wait...
</pre></div>
</div></div>

  <p>The R session information (including the OS info, R version and all
    packages used):</p>

<div class="chunk" id="session-info"><div class="rcode"><div class="source"><pre class="knitr r">    <span class="hl kwd">sessionInfo</span><span class="hl std">()</span>
</pre></div>
<div class="output"><pre class="knitr r">## R version 4.0.3 (2020-10-10)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Catalina 10.15.7
## 
## Matrix products: default
## BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] knitr_1.31        interflex_1.1.4   devtools_2.3.2    usethis_2.0.0    
##  [5] mgcv_1.8-33       nlme_3.1-151      swfscMisc_1.3     sjmisc_2.8.6     
##  [9] sjlabelled_1.1.7  forcats_0.5.1     stringr_1.4.0     dplyr_1.0.4      
## [13] purrr_0.3.4       readr_1.4.0       tidyr_1.1.2       tibble_3.0.6     
## [17] ggplot2_3.3.3     tidyverse_1.3.0   lfe_2.8-6         Matrix_1.3-2     
## [21] estimatr_0.30.2   data.table_1.13.6 pacman_0.5.1     
## 
## loaded via a namespace (and not attached):
##   [1] readxl_1.3.1         backports_1.2.1      plyr_1.8.6           splines_4.0.3       
##   [5] digest_0.6.27        foreach_1.5.1        htmltools_0.5.1.1    magrittr_2.0.1      
##   [9] memoise_2.0.0        tensor_1.5           doParallel_1.0.16    remotes_2.2.0       
##  [13] recipes_0.1.15       modelr_0.1.8         gower_0.2.2          sandwich_3.0-0      
##  [17] prettyunits_1.1.1    colorspace_2.0-0     rvest_0.3.6          haven_2.3.1         
##  [21] xfun_0.20            callr_3.5.1          crayon_1.4.0         jsonlite_1.7.2      
##  [25] spatstat_1.64-1      spatstat.data_1.7-0  survival_3.2-7       zoo_1.8-8           
##  [29] iterators_1.0.13     glue_1.4.2           polyclip_1.10-0      gtable_0.3.0        
##  [33] ipred_0.9-9          emmeans_1.5.4        pkgbuild_1.2.0       maps_3.3.0          
##  [37] abind_1.4-5          scales_1.1.1         mvtnorm_1.1-1        DBI_1.1.1           
##  [41] Rcpp_1.0.6           xtable_1.8-4         gridGraphics_0.5-1   Formula_1.2-4       
##  [45] stats4_4.0.3         lava_1.6.8.1         prodlim_2019.11.13   httr_1.4.2          
##  [49] RColorBrewer_1.1-2   ellipsis_0.3.1       pkgconfig_2.0.3      nnet_7.3-15         
##  [53] dbplyr_2.1.0         deldir_0.2-9         caret_6.0-86         ggplotify_0.0.5     
##  [57] tidyselect_1.1.0     rlang_0.4.10         reshape2_1.4.4       munsell_0.5.0       
##  [61] cellranger_1.1.0     tools_4.0.3          cachem_1.0.1         cli_2.3.0           
##  [65] generics_0.1.0       broom_0.7.4          evaluate_0.14        fastmap_1.1.0       
##  [69] yaml_2.2.1           goftest_1.2-2        ModelMetrics_1.2.2.2 processx_3.4.5      
##  [73] fs_1.5.0             xml2_1.3.2           pcse_1.9.1.1         compiler_4.0.3      
##  [77] rstudioapi_0.13      testthat_3.0.1       spatstat.utils_2.0-0 mapdata_2.3.0       
##  [81] reprex_1.0.0         stringi_1.5.3        highr_0.8            ps_1.5.0            
##  [85] desc_1.2.0           lattice_0.20-41      markdown_1.1         vctrs_0.3.6         
##  [89] pillar_1.4.7         lifecycle_0.2.0      BiocManager_1.30.10  lmtest_0.9-38       
##  [93] estimability_1.3     insight_0.12.0       R6_2.5.0             gridExtra_2.3       
##  [97] sessioninfo_1.1.1    Lmoments_1.3-1       codetools_0.2-18     MASS_7.3-53         
## [101] assertthat_0.2.1     pkgload_1.1.0        rprojroot_2.0.2      withr_2.4.1         
## [105] parallel_4.0.3       hms_1.0.0            grid_4.0.3           rpart_4.1-15        
## [109] timeDate_3043.102    coda_0.19-4          class_7.3-18         rmarkdown_2.6       
## [113] rvcheck_0.1.8        pROC_1.17.0.1        lubridate_1.7.9.2
</pre></div>
<div class="source"><pre class="knitr r">    <span class="hl kwd">Sys.time</span><span class="hl std">()</span>
</pre></div>
<div class="output"><pre class="knitr r">## [1] &quot;2021-02-11 20:42:01 CET&quot;
</pre></div>
</div></div>


</body>
</html>
